﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using Eds.Model;
using NHibernate.Criterion;

namespace Eds.Sql
{
    public class ReceiveMailSearch : MailSearch
    {
        private ISession _session;
        public ReceiveMailSearch(ISession session)
            : base(session)
        {
            _session = session;
            MailType = 0;
            //HasReply = false;
        }

        //public Boolean HasReply { get; set; }


        public IList<ReceiveMail> Select()
        {
            ICriteria criteria = _session.CreateCriteria<ReceiveMail>();
            criteria.Add(Restrictions.Eq("MailType", MailType));

            //if (HasReply)
            //    criteria.Add(Restrictions.Gt("ReferenceId", -1));
            //else
            //    criteria.Add(Restrictions.Eq("ReferenceId", -1));


            if (PageSize > 0)
                criteria.SetFirstResult(PageSize * CurrentPage).SetMaxResults(PageSize);

            return criteria.List<ReceiveMail>();
        }

      

    }
}
